require 'net/http'

module ESI

  # works like a hash object and sends the HTTP Header
  class HTTPHeader
    include Net::HTTPHeader

    def initialize(params)
      initialize_http_header(nil)
      params.each { |k,v| self[k] = v }
    end

    def write(method, path, socket, ver="1.0")
      buf = "#{method} #{path} HTTP/#{ver}\r\n"
      each_capitalized do |k,v|
        buf << "#{k}: #{v}\r\n"
      end
      buf << "\r\n"
      socket.write buf
    end

  end

end
